/*
 * IntervalArithmeticCalculatorView.java
 */

package intervalarithmeticcalculator;

import calculatorParser.Scanner;
import calculatorParser.stackDeikstri;
import intervalMath.KaucherIntervalArithmetic;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import calculatorParser.Scanner;

/**
 * The application's main frame.
 */
public class IntervalArithmeticCalculatorView extends FrameView {

    public IntervalArithmeticCalculatorView(SingleFrameApplication app) {
        super(app);

        initComponents();
        this.getFrame().setResizable(false);
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                //statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
       // statusAnimationLabel.setIcon(idleIcon);
       // progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                       // statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                   // progressBar.setVisible(true);
                   // progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                  //  statusAnimationLabel.setIcon(idleIcon);
                    //progressBar.setVisible(false);
                  //  progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                   // statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                  //  progressBar.setVisible(true);
                  ////  progressBar.setIndeterminate(false);
                   // progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = IntervalArithmeticCalculatorApp.getApplication().getMainFrame();
            aboutBox = new IntervalArithmeticCalculatorAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        IntervalArithmeticCalculatorApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        inputLine = new javax.swing.JTextField();
        plusButton = new javax.swing.JButton();
        minusButton = new javax.swing.JButton();
        multBUtton = new javax.swing.JButton();
        divButton = new javax.swing.JButton();
        sinButton = new javax.swing.JButton();
        cosButton = new javax.swing.JButton();
        lnButton = new javax.swing.JButton();
        expButton = new javax.swing.JButton();
        sqrtButton = new javax.swing.JButton();
        resButton = new javax.swing.JButton();
        openBracketButton = new javax.swing.JButton();
        closeBracketButton = new javax.swing.JButton();
        clearButton = new javax.swing.JButton();
        intervalButton = new javax.swing.JButton();
        errorMessage = new javax.swing.JLabel();
        dualButton = new javax.swing.JButton();
        pro = new javax.swing.JButton();
        infButton = new javax.swing.JButton();
        supButton = new javax.swing.JButton();
        oppButton = new javax.swing.JButton();
        invButton = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        mainPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        mainPanel.setMaximumSize(new java.awt.Dimension(325, 273));
        mainPanel.setMinimumSize(new java.awt.Dimension(325, 273));
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                mainPanelComponentResized(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(IntervalArithmeticCalculatorView.class);
        inputLine.setText(resourceMap.getString("inputLine.text")); // NOI18N
        inputLine.setName("inputLine"); // NOI18N

        plusButton.setText(resourceMap.getString("plusButton.text")); // NOI18N
        plusButton.setName("plusButton"); // NOI18N
        plusButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                plusButtonMouseClicked(evt);
            }
        });

        minusButton.setText(resourceMap.getString("minusButton.text")); // NOI18N
        minusButton.setName("minusButton"); // NOI18N
        minusButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                minusButtonMouseClicked(evt);
            }
        });

        multBUtton.setText(resourceMap.getString("multBUtton.text")); // NOI18N
        multBUtton.setName("multBUtton"); // NOI18N
        multBUtton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                multBUttonMouseClicked(evt);
            }
        });

        divButton.setText(resourceMap.getString("divButton.text")); // NOI18N
        divButton.setName("divButton"); // NOI18N
        divButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                divButtonMouseClicked(evt);
            }
        });

        sinButton.setText(resourceMap.getString("sinButton.text")); // NOI18N
        sinButton.setName("sinButton"); // NOI18N
        sinButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sinButtonMouseClicked(evt);
            }
        });

        cosButton.setText(resourceMap.getString("cosButton.text")); // NOI18N
        cosButton.setName("cosButton"); // NOI18N
        cosButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cosButtonMouseClicked(evt);
            }
        });

        lnButton.setText(resourceMap.getString("lnButton.text")); // NOI18N
        lnButton.setName("lnButton"); // NOI18N
        lnButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lnButtonMouseClicked(evt);
            }
        });

        expButton.setText(resourceMap.getString("expButton.text")); // NOI18N
        expButton.setName("expButton"); // NOI18N
        expButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                expButtonMouseClicked(evt);
            }
        });

        sqrtButton.setText(resourceMap.getString("sqrtButton.text")); // NOI18N
        sqrtButton.setName("sqrtButton"); // NOI18N
        sqrtButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                sqrtButtonMouseClicked(evt);
            }
        });

        resButton.setText(resourceMap.getString("resButton.text")); // NOI18N
        resButton.setName("resButton"); // NOI18N
        resButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                resButtonMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                resButtonMouseEntered(evt);
            }
        });

        openBracketButton.setText(resourceMap.getString("openBracketButton.text")); // NOI18N
        openBracketButton.setName("openBracketButton"); // NOI18N
        openBracketButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                openBracketButtonMouseClicked(evt);
            }
        });

        closeBracketButton.setText(resourceMap.getString("closeBracketButton.text")); // NOI18N
        closeBracketButton.setName("closeBracketButton"); // NOI18N
        closeBracketButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                closeBracketButtonMouseClicked(evt);
            }
        });

        clearButton.setText(resourceMap.getString("clearButton.text")); // NOI18N
        clearButton.setName("clearButton"); // NOI18N
        clearButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                clearButtonMouseClicked(evt);
            }
        });

        intervalButton.setText(resourceMap.getString("intervalButton.text")); // NOI18N
        intervalButton.setName("intervalButton"); // NOI18N
        intervalButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                intervalButtonMouseClicked(evt);
            }
        });

        errorMessage.setText(resourceMap.getString("errorMessage.text")); // NOI18N
        errorMessage.setName("errorMessage"); // NOI18N

        dualButton.setText(resourceMap.getString("dualButton.text")); // NOI18N
        dualButton.setName("dualButton"); // NOI18N
        dualButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                dualButtonMouseClicked(evt);
            }
        });

        pro.setText(resourceMap.getString("pro.text")); // NOI18N
        pro.setName("pro"); // NOI18N
        pro.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                proMouseClicked(evt);
            }
        });

        infButton.setText(resourceMap.getString("infButton.text")); // NOI18N
        infButton.setName("infButton"); // NOI18N
        infButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                infButtonMouseClicked(evt);
            }
        });

        supButton.setText(resourceMap.getString("supButton.text")); // NOI18N
        supButton.setName("supButton"); // NOI18N

        oppButton.setText(resourceMap.getString("oppButton.text")); // NOI18N
        oppButton.setName("oppButton"); // NOI18N
        oppButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                oppButtonMouseClicked(evt);
            }
        });

        invButton.setText(resourceMap.getString("invButton.text")); // NOI18N
        invButton.setName("invButton"); // NOI18N
        invButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                invButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(errorMessage)
                        .addContainerGap(404, Short.MAX_VALUE))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(intervalButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                                .addGap(13, 13, 13)
                                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(oppButton, 0, 0, Short.MAX_VALUE)
                                    .addComponent(divButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(multBUtton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(minusButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(plusButton, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(openBracketButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(closeBracketButton, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(supButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(infButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(invButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(pro, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(dualButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)))
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(expButton, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                            .addComponent(lnButton, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                            .addComponent(sqrtButton, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                            .addComponent(cosButton, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(resButton, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(sinButton, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))
                        .addGap(154, 154, 154))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(inputLine, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(inputLine, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(errorMessage)
                .addGap(11, 11, 11)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(intervalButton)
                    .addComponent(openBracketButton)
                    .addComponent(clearButton)
                    .addComponent(resButton)
                    .addComponent(closeBracketButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(plusButton)
                    .addComponent(dualButton)
                    .addComponent(sinButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(minusButton)
                    .addComponent(pro)
                    .addComponent(cosButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(multBUtton)
                    .addComponent(invButton)
                    .addComponent(sqrtButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(divButton)
                    .addComponent(infButton)
                    .addComponent(lnButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(supButton)
                    .addComponent(oppButton)
                    .addComponent(expButton))
                .addGap(41, 41, 41))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(IntervalArithmeticCalculatorView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setText(resourceMap.getString("aboutMenuItem.text")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setComponent(mainPanel);
        setMenuBar(menuBar);
    }// </editor-fold>//GEN-END:initComponents

    private void plusButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_plusButtonMouseClicked
        inputLine.setText(inputLine.getText() + "+");
        inputLine.requestFocus();
        errorMessage.setText("");
        
    }//GEN-LAST:event_plusButtonMouseClicked

    private void minusButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_minusButtonMouseClicked
        inputLine.setText(inputLine.getText() + "-");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_minusButtonMouseClicked

    private void multBUttonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_multBUttonMouseClicked
        inputLine.setText(inputLine.getText() + "*");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_multBUttonMouseClicked

    private void divButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_divButtonMouseClicked
        inputLine.setText(inputLine.getText() + "/");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_divButtonMouseClicked

    private void sinButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sinButtonMouseClicked
        inputLine.setText(inputLine.getText() + "sin");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_sinButtonMouseClicked

    private void cosButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cosButtonMouseClicked
        inputLine.setText(inputLine.getText() + "cos");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_cosButtonMouseClicked

    private void lnButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lnButtonMouseClicked
        inputLine.setText(inputLine.getText() + "ln");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_lnButtonMouseClicked

    private void expButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_expButtonMouseClicked
        inputLine.setText(inputLine.getText() + "exp");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_expButtonMouseClicked

    private void sqrtButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sqrtButtonMouseClicked
        inputLine.setText(inputLine.getText() + "sqrt");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_sqrtButtonMouseClicked

    private void openBracketButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_openBracketButtonMouseClicked
        inputLine.setText(inputLine.getText() + "(");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_openBracketButtonMouseClicked

    private void closeBracketButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_closeBracketButtonMouseClicked
       inputLine.setText(inputLine.getText() + ")");
       inputLine.requestFocus();
       errorMessage.setText("");
    }//GEN-LAST:event_closeBracketButtonMouseClicked

    private void resButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_resButtonMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_resButtonMouseEntered

    private void resButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_resButtonMouseClicked
        String resultExpression = inputLine.getText();
        try{
            List<String> list = Scanner.scanString(resultExpression);
            KaucherIntervalArithmetic result =
                    (KaucherIntervalArithmetic)stackDeikstri.fromRPNToInterval(stackDeikstri.generateRPN(list));
            inputLine.setText(result.toString());
            errorMessage.setText("");
            inputLine.requestFocus();
        }
        catch(Exception e) {
            errorMessage.setText(e.getMessage());
        }
        
    }//GEN-LAST:event_resButtonMouseClicked

    private void clearButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clearButtonMouseClicked
        inputLine.setText("");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_clearButtonMouseClicked

    private void mainPanelComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_mainPanelComponentResized
        return;
    }//GEN-LAST:event_mainPanelComponentResized

    private void intervalButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_intervalButtonMouseClicked
        inputLine.setText(inputLine.getText() + "[0.0;0.0]");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_intervalButtonMouseClicked

    private void dualButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dualButtonMouseClicked
        inputLine.setText(inputLine.getText() + "dual");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_dualButtonMouseClicked

    private void proMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_proMouseClicked
        inputLine.setText(inputLine.getText() + "pro");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_proMouseClicked

    private void infButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_infButtonMouseClicked
        inputLine.setText(inputLine.getText() + "inf");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_infButtonMouseClicked

    private void oppButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_oppButtonMouseClicked
        inputLine.setText(inputLine.getText() + "opp");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_oppButtonMouseClicked

    private void invButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_invButtonMouseClicked
        inputLine.setText(inputLine.getText() + "inv");
        inputLine.requestFocus();
        errorMessage.setText("");
    }//GEN-LAST:event_invButtonMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton clearButton;
    private javax.swing.JButton closeBracketButton;
    private javax.swing.JButton cosButton;
    private javax.swing.JButton divButton;
    private javax.swing.JButton dualButton;
    private javax.swing.JLabel errorMessage;
    private javax.swing.JButton expButton;
    private javax.swing.JButton infButton;
    private javax.swing.JTextField inputLine;
    private javax.swing.JButton intervalButton;
    private javax.swing.JButton invButton;
    private javax.swing.JButton lnButton;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JButton minusButton;
    private javax.swing.JButton multBUtton;
    private javax.swing.JButton openBracketButton;
    private javax.swing.JButton oppButton;
    private javax.swing.JButton plusButton;
    private javax.swing.JButton pro;
    private javax.swing.JButton resButton;
    private javax.swing.JButton sinButton;
    private javax.swing.JButton sqrtButton;
    private javax.swing.JButton supButton;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
